import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'

Vue.use(Vuex)
const moduleA = {
    state: { ma:1 },
    mutations: { 
        maCount(state) { 
            state.ma++
        }
     },
    getters: { 
        maGet(state) { 
            return state.ma+100
        }
     }
  }
  
  const moduleB = {
    state: { mb:3 },
    mutations: { 
        mbCount(state, getters, rootState,rootGetters) { 
            console.log('根22号',state )
            console.log('哈22哈',rootState )
            state.mb++
        }
      },
      actions: {
          actyoxi(ctx) { 
              console.log('拉拉', ctx)
              ctx.commit('mbCount',1,2,3)
          }
      },
    getters: { 
        mbGet(state, getters, rootState,rootGetters  ) {
            return state.mb+301
        }
     }
}
  /*
  <div>123木头人{{this.$store.state.a.ma}}</div>----单个模块里的state需要在前面加module名
<div>456木头人{{this.$store.getters.maGet}}</div>----对于getters里的属性似乎不需要在前面加module名
<div>呵呵{{this.$store.state.haha}}</div>----new Vuex.Store里的state取值方法
  */
export default new Vuex.Store({
    state: {
        haha:98
    },
    modules: {
        a:moduleA,
        b:moduleB
    }
  })